import server from "./server"

/**
 * 获取最新文章
 */
export const getTitleNewLsit = async (pageIndex, IV) => {
	console.log(pageIndex, IV);
	return await server({
		url: "api/Article/New",
		data: {
			PageIndex: pageIndex,
			IV
		}
	})
}

/**
 * 创建文章
 */
export const creatTitleApi = async (title, text, IsPublic, IsExclusive, Tags) => {
	return await server({
		url: "api/Article/Create",
		data: {
			Title: title,
			Text: text,
			IsPublic,
			IsExclusive,
			Tags
		}
	})
}

/**
 * 续写文章
 */
export const addTitleApi = async (title, text, parentId) => {
	return await server({
		url: "api/Article/Add",
		data: {
			Title: title,
			Text: text,
			ParentId: parentId
		}
	})
}

/**
 * 获取主文章信息
 */
export const getArticleMain = async (ArticleMainId) => {
	return await server({
		url: "api/Article/Main",
		data: {
			ArticleMainId
		}
	})
}

/**
 * 获取文章信息
 */
export const getArticleSub = async (Type, ArticleSubId) => {
	return await server({
		url: "api/Article/Sub",
		data: {
			Type,
			ArticleSubId
		}
	})
}

/**
 * 文章点赞
 */
export const thumbsArticle = async (ArticleSubId, IsChecked) => {
	return await server({
		url: "api/Thumbs/SetArticle",
		data: {
			ArticleSubId,
			IsChecked
		}
	})
}

/**
 * 评论点赞
 */
export const thumbsRemarkApi = async (ArticleSubId, IsChecked, RemarkId) => {
	return await server({
		url: "api/Thumbs/SetRemark",
		data: {
			ArticleSubId,
			IsChecked,
			RemarkId
		}
	})
}

/**
 * 文章推荐
 */
export const recommendApi = async (ArticleSubId, IsChecked) => {
	return await server({
		url: "api/Recommend/SetRecommend",
		data: {
			ArticleSubId,
			IsChecked
		}
	})
}

/**
 * 新增评论
 */
export const addRemarkApi = async (ArticleSubId, ParentId, ToUser, Text) => {
	return await server({
		url: "api/Remark/Add",
		data: {
			ArticleSubId,
			ParentId,
			ToUser,
			Text
		}
	})
}

/**
 * 获取根评论
 */
export const getRootRemarkApi = async (ArticleSubId, IV, PageIndex) => {
	return await server({
		url: "api/Remark/RootList",
		method: "GET",
		data: {
			ArticleSubId,
			IV,
			PageIndex
		}
	})
}

/**
 * 获取子评论
 */
export const getSubRemarkApi = async (RemarkId, IV, PageIndex) => {
	return await server({
		url: "api/Remark/SubList",
		method: "GET",
		data: {
			RemarkId,
			IV,
			PageIndex
		}
	})
}

/**
 * 设置收藏
 */
export const setCollectApi = async (ArticleMainId, IsChecked) => {
	return await server({
		url: "api/Collect/SetCollect",
		method: "POST",
		data: {
			ArticleMainId, IsChecked
		}
	})
}